<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<c:set var="ctx" value="${pageContext.request.contextPath }" />
<link rel="stylesheet"
	href="${ctx }/resources/js/select2/select2.min.css" />
<script type="text/javascript"
	src="${ctx }/resources/js/select2/select2.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/js/select2/zh-CN.js"></script>
<script type="text/javascript">
$(function() {
	webside.form.site.SiteForm();
})
function doSaveLogo() {
        var fileName = $("#logo").val();
        console.log("!!!!+++"+fileName);
        var type = fileName.split(".");
        var ftype = type[type.length - 1]; //获取文件后缀

        $.ajaxFileUpload({
            url : '${ctx}/files/upload/' + ftype,
            secureuri : false, //是否需要安全协议，一般设置为false
            fileElementId : [ 'logo' ], //文件上传域的ID
            dataType : 'json', //返回值类型 一般设置为json
            success : function(data, status) //服务器成功响应处理函数
            {

                if (data.result == 0) {
                    var fileId = data.data[0].id;
                    var filePath = '/files/view/jpg/' + fileId;
                    $("#hiddenLogo").val(filePath);
                    //显示图片
                    $("#imgLogo").attr("src",
                            '${ctx }/files/view/jpg/' + fileId);
                    //显示名字
                    $("#laLogo").html(data.data[0].name);
                }
            },
            error : function(data, status, e) //服务器响应失败处理函数
            {
                alert(e);
            }
        });
    }
</script>
<script src="${ctx }/resources/js/upload/ajaxfileupload.js"
	type="text/javascript"></script>
 


<style>
.iconShow
{
	padding-left: 10px; 
	padding-top: 3px;
}
.source-icon
{
	 width:95%;
	 float:left;
}
@media screen and (max-width: 374px){
	.source-icon
	{
		 width:82%;
	}
}
@media screen and (min-width: 375px) and (max-width: 449px){
	.source-icon
	{
		 width:85%;
	}
}
@media screen and (min-width: 450px) and (max-width: 1279px) {
	.source-icon
	{
		 width:90%;
	}
}
@media screen and (min_width: 1280px) {
	.source-icon
	{
		 width:90%;
	}
}
</style>
<div class="page-header">
	<h1>
		<c:if test="${empty site}">
		新增字典管理
		</c:if>
		<c:if test="${!empty site}">
		编辑字典管理
		</c:if>
	</h1>
</div>
<div class="row" style="margin-top: 5px;">
	<div class="col-xs-12">
		<form id="sitesForm" name="sitesForm" class="form-horizontal" role="form" method="post">
			<c:if test="${!empty site}">
				<input type="hidden" id="pageNum" name="pageNum" value="${page.pageNum }"> 
				<input type="hidden" id="pageSize" name="pageSize" value="${page.pageSize }"> 
				<input type="hidden" id="orderByColumn" name="orderByColumn" value="${page.orderByColumn }"> 
				<input type="hidden" id="orderByType" name="orderByType" value="${page.orderByType }">
				<input type="hidden"  id='id' name="appid" value="${site.appid }">
				 
			</c:if>
			
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="name">站点名称</label>
				<div class="col-sm-10">
					<div class="clearfix">
			        
						<input class="form-control" name="name" id="name" type="text"
							value="${site.name }" placeholder="站点名称" />
	                </div>
                </div>
      		</div>
      		<div class="form-group">
                <label class="control-label col-sm-1 no-padding-right" for="logo">站点logo</label>
                <div class="col-sm-10">
                    <div class="clearfix">
                        <input class="form-control" name="files" id="logo" type="file" placeholder="站点LOGO" /> 
                        <img id="imgLogo" alt=""
                            <c:if test="${null eq  site.logo}">src="${ctx}/resources/images/xx.png"</c:if>
                            <c:if test="${site.logo != null}">src="${ctx}${site.logo}"</c:if>
                            width="175px" height="100px"/> 
                        <label id="laLogo"></label>
                        <input type="button" id="but" onclick="javascript:doSaveLogo();"
                            value="上传" class="btn btn-primary btn-sm" name="files" /> 
                        <input type="hidden" id="hiddenLogo" name="logo" value="${site.logo }"/>
                    </div>
                    <label id='m' style='font-family: verdana; color: red'>LOGO尺寸比例要求16:9，推荐尺寸xxx*xxx</label>
                </div>
            </div>
            <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="url">站点网址</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="url"  id="url" 
						 type="text" value="${site.url }" placeholder="站点网址" />
					</div>
				</div>
			</div>
	         <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="description">站点介绍</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="description"  id="description" 
						 type="text" value="${site.description }" placeholder="站点介绍" />
					</div>
				</div>
			</div>
	        <div class="form-group">
                <label class="control-label col-sm-1 no-padding-right"
                    for="recommendLevel">平台类型</label>
                <div class="col-sm-10">
                    <div class="clearfix">
                        <select id="type" class="form-control"
                            name='type'>
                            <option value=""
                                <c:if test="${site.type eq null}">selected="selected"</c:if>>请选择</option>
                            <c:forEach items="${listType}" var="t">
                                <option value="${t.name}"
                                    <c:if test="${site.type eq t.name}">selected="selected"</c:if>>${t.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-1 no-padding-right"
                    for="recommendLevel">资源分组</label>
                <div class="col-sm-10">
                    <div class="clearfix">
                        <select id="distinguishName" class="form-control"
                            name='distinguishName'>
                            <option value=""
                                <c:if test="${site.distinguishName eq null}">selected="selected"</c:if>>请选择</option>
                            <c:forEach items="${listDistinguish}" var="t">
                                <option value="${t.name}-${t.id}"
                                    <c:if test="${site.distinguishName eq t.name}">selected="selected"</c:if>>${t.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </div>
	        <%-- <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="sort">排序</label>
				<div class="col-sm-10">
				<div class="clearfix">
					<input class="form-control" name="sort" id="sort" type="text"
						value="${site.sort}" placeholder="排序"  onkeyup="value=value.replace(/[^(\d)]/g,'')"/>
						<label>(只能输入0-9的数字)</label>
				</div>
				</div>
			</div>
			 --%>
			
		</form>
		<div class="hr hr-dotted"></div>
	</div>
</div>
<div class="center">
	<button id="btnAdd" type="button" 
	onclick="javascript:$('#sitesForm').submit();" 
	class="btn btn-success btn-sm">
		<i class="fa fa-user-plus"></i>&nbsp;
		<c:if test="${empty site}">
		添加
		</c:if>
		<c:if test="${!empty site}">
		保存
		</c:if>
	</button>
	<button id="btn" type="button"
		onclick="webside.common.loadPage('/site/listUI.html<c:if test="${!empty site}">?page=${page.pageNum }&rows=${page.pageSize }&sidx=${page.orderByColumn }&sord=${page.orderByType }</c:if>')"
		class="btn btn-info btn-sm">
		<i class="fa fa-undo"></i>&nbsp;返回
	</button>
</div>
 